<%@ page import="java.util.ArrayList" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %><%--
  Created by IntelliJ IDEA.
  User: snowy
  Date: 2022/7/3
  Time: 19:24
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>全部订单</title>
<%--    <script src="bootstrap.min.js"></script>--%>
    <link href="css/bootstrap.min.css" rel="stylesheet">
    <link href="css/styles.css" rel="stylesheet">
    <link href="css/animate.min.css" rel="stylesheet">
    <style>
        body{
            background:url(image/背景图.jpg) no-repeat center top;
            background-size:cover;
            background-attachment:fixed;
        }
        form{
            align-content: center;
            color: white;
            background-color: rgba(38, 39, 40, 0.85);
            border: 3px solid #ffdd00;
        }
        nav{
            background: #0B0B0B;
        }
        h2{
            color: whitesmoke;
        }
        table{
            border:1px solid rgba(246, 204, 21, 1);
            color: whitesmoke;
            background-color: rgba(38, 39, 40, 0.85);
        }
    </style>
    <jsp:useBean id="orderBean" class="bean.Orders" scope="session"/>
</head>

<body id="home">
<header style="background: #0B0B0B">
    <nav id="main-nav" class="navbar navbar-default navbar-fixed-top" role="banner">
        <div class="container">
            <div class="navbar-header">
                <a class="navbar-brand" style="float:left"><img src="image/logo.png" alt="logo"></a>
            </div>

            <div class="collapse navbar-collapse navbar-right">
                <ul class="nav navbar-nav">
                    <li class="scroll "><a href="index.jsp">首页</a></li>
                    <li class="scroll"><a href="person.jsp">个人信息</a></li>
                    <li class="scroll active"><a href="index.jsp">我的订单</a></li>
                    <li class="scroll"><a href="#">联系客服</a></li>
                </ul>
            </div>
        </div>
    </nav></header>
<br><br><br><br>
    <div class="login-box">
        <form>
            订单信息查询：
            <button><a href='OrderServlet?condition=全部订单'>全部订单</a></button>
            <button><a href='OrderServlet?condition=成功预订'>成功预订</a></button>
            <button><a href='OrderServlet?condition=已取消'>已取消</a></button>
        </form></div>

<h2>全部订单</h2>
   <table class="table">
        <thead>
        <tr>
            <th>订单编号</th>
            <th>时间</th>
            <th>民宿</th>
            <th>房间</th>
            <th>入住时间</th>
            <th>离店时间</th>
            <th>订单状态</th>
            <th>修改订单状态</th>
        </tr>

        </thead>
       <%
//           ArrayList<String> orderId=new ArrayList<>();
//           ArrayList<String>  roomId=new ArrayList<>();
//           ArrayList <String>hotelId=new ArrayList<>();
//           ArrayList <String>orderdate=new ArrayList<>();
//           ArrayList<String> orderCondition=new ArrayList<>();
           ArrayList<String> checkin= orderBean.getCheckin();
           ArrayList<String> checkout= orderBean.getCheckout();
           ArrayList<String> orderId=orderBean.getOrderId();
           ArrayList<String> roomId=orderBean.getRoomId();
           ArrayList<String> roomName=orderBean.getRoomName();
           ArrayList<String> hotelId= orderBean.getHotelId();
           ArrayList<String> orderdate= orderBean.getOrderdate();
           ArrayList<String> orderCondition=orderBean.getOrderCondition();
//           String condition=orderBean.getCondition();
           for (int i=0;i<orderId.size();i++){
               String rid=roomId.get(i);
               String hid=hotelId.get(i);
               String od=orderdate.get(i);
               String oc=orderCondition.get(i);
               String oid=orderId.get(i);
               String ci=checkin.get(i);
               String co=checkout.get(i);
               String rn=roomName.get(i);
               String Now = new SimpleDateFormat("yyyyMMdd").format(new Date());
               int check=Integer.valueOf(ci).intValue();
               int now=Integer.valueOf(Now).intValue();
               if (oc.equals("成功预订")){
                   out.print(" <tr>");
                   out.print(" <td>"+oid+"</td>");
                   out.print(" <td>"+od+"</td>");
                   out.print(" <td>"+hid+"</td>");
                   out.print("<td>"+rn+"</td>");
                   out.print(" <td>"+ci+"</td>");
                   out.print("<td>"+co+"</td>");
                   out.print(" <td>"+oc+"</td>");
                   System.out.println("order123行"+check);
                   System.out.println("order124行"+now);
                   if (check-now>1) {
                       out.print("<td><button><a href='OEServlet?orderID=" + oid + "&RoomID=" + rid + "&Checkin=" + ci + "'>取消订单</a></button></td>");
                   }else {
                       out.print("<td></td>");
                   }

                   out.print("</tr>");
               }
               if (oc.equals("已取消")){
                   out.print(" <tr>");
                   out.print(" <td>"+oid+"</td>");
                   out.print(" <td>"+od+"</td>");
                   out.print(" <td>"+hid+"</td>");
                   out.print("<td>"+rn+"</td>");
                   out.print(" <td>"+ci+"</td>");
                   out.print("<td>"+co+"</td>");
                   out.print(" <td>"+oc+"</td>");
                   out.print("<td></td>");
                   out.print("</tr>");

               }

           }
       %>
    </table>

<%--直接显示全部订单信息--%>
</body>
</html>
